package com.cty.statics;

import com.cty.Calculator;

//代理类
public class StaticProxyCalculator implements Calculator {

    //代理类也要实现目标类的接口
    //原因:代理类和目标类的业务是一样的
    //传入目标类的对象

    private Calculator target;

    //传入目标类
    public StaticProxyCalculator(Calculator target) {
        this.target = target;
    }
    @Override
    public int add(int i, int j) {
        System.out.println("i = " + i + ", j = " + j);
        //当到核心业务时调用目标类的核心业务
        int res = target.add(i,j);
        System.out.println("res = " + res);
        return res;
    }

    @Override
    public int sub(int i, int j) {
        return 0;
    }

    @Override
    public int mul(int i, int j) {
        return 0;
    }

    @Override
    public int div(int i, int j) {
        return 0;
    }
}
